package com.smedi.ismedi.web.starter.thread;

import com.alibaba.ttl.threadpool.TtlExecutors;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;


@Configuration
@EnableAsync
public class ThreadPool {

    public static final ExecutorService IO_INSTANCE = TtlExecutors.getTtlExecutorService(new BaseThreadPool());

    public static final String IO_INSTANCE_BEAN = "IO_INSTANCE_BEAN";

    @Bean(IO_INSTANCE_BEAN)
    public Executor executor() {
        return IO_INSTANCE;
    }
}
